VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "Line"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
'*************************************************************************
'  This source code is provided "as is" and as an unsupported sample of
'  a Microsoft Visual Basic application that incorporates the MapPoint 2002
'  object model and ActiveX control. It can only  be used in accordance with
'  the terms and conditions of the Microsoft MapPoint 2002 and
'  Microsoft Visual Basic End User License Agreements.
'*************************************************************************

Private m_sName As String
Private m_sPenData As String
Private m_oDataPoints As SpatialDataImport.DataPoints

Public Property Get Name() As String
    Name = m_sName
End Property

Public Property Let Name(sNewValue As String)
    m_sName = sNewValue
End Property

Public Property Get PenData() As String
    PenData = m_sPenData
End Property

Public Property Let PenData(sNewValue As String)
    m_sPenData = sNewValue
End Property

Public Property Get DataPoints() As SpatialDataImport.DataPoints
    Set DataPoints = m_oDataPoints
End Property

Public Property Set DataPoints(oNewValue As SpatialDataImport.DataPoints)
    Set m_oDataPoints = oNewValue
End Property

Private Sub Class_Initialize()
    Set m_oDataPoints = New SpatialDataImport.DataPoints
End Sub

Private Sub Class_Terminate()
    Set m_oDataPoints = Nothing
End Sub

Public Function RenderShape(omMap As MapPoint.Map) As MapPoint.Location
'**********************************************************************************
    ' Date: 4/3/2001
    ' Abstract: Generates a Shape object and a Location object for this Line.
    ' Assumptions:
    ' Notes:
'**********************************************************************************

    Dim oDataPoint As SpatialDataImport.DataPoint
    Dim omLocArray() As MapPoint.Location
    Dim omLocation As MapPoint.Location
    Dim omShape As MapPoint.Shape
    Dim lDataPointCount As Long
    Dim lArrayIndex As Long
    
    On Error GoTo errorHandler
    
    'Get the number of data points that define this region.
    lDataPointCount = m_oDataPoints.Count
    
    'Make sure there is at least 1 data point.
    If lDataPointCount <> 0 Then
    
        'Loop through all the DataPoints.
        For Each oDataPoint In m_oDataPoints
        
            'Create a Location object at this DataPoint's coordinates.
            Set omLocation = omMap.GetLocation(oDataPoint.Latitude, oDataPoint.Longitude)
            
            'Make sure we got a location.  If so, then add it to our Location array.
            If Not omLocation Is Nothing Then
                
                'Re-Dimension our Location array to make room for the new Location.
                lArrayIndex = lArrayIndex + 1
                ReDim Preserve omLocArray(1 To lArrayIndex)
                
                'Add the Location object to the array.
                Set omLocArray(lArrayIndex) = omLocation
                
            End If
            
        Next oDataPoint
        
        'Create a Shape object from the Location array.
        Set omShape = omMap.Shapes.AddPolyline(omLocArray)
        
        'If we have a Name to apply, then apply it.
        If Len(m_sName) <> 0 Then
            omShape.Name = m_sName
        End If
        omShape.Line.Weight = 2
        
        'Return a union of all the Locations that define this Line.
        Set omLocation = omMap.Union(omLocArray)
        Set RenderShape = omLocation
    End If
    
    Exit Function
errorHandler:
    MsgBox "Error in RenderShape" & vbCrLf _
         & "Error Number: " & Err.Number & vbCrLf _
         & "Error Description: " & Err.Description, vbExclamation, App.Title
End Function


